<template>
	<view class="page">
		<view class="box">
			<view class="head">
				<view class="info">
					<image :src="$wanlshop.oss(user.avatar)" mode="aspectFill"></image>
					<view class="">
						<text>{{user.nickname}}</text>
						<view class="store" @tap="$wanlshop.auth('/pages/restaurant/user/store/store')">
							<text>{{common.store.name}}</text>
							<uni-icons type="right" size="16" :color="`#fff`"></uni-icons>
						</view>
					</view>
				</view>
			</view>
			<view class="content">
				<view class="money">
					<text>账户余额（元）</text>
					<text>{{user.money && user.money.money1 || '0.00'}}</text>
				</view>
				
				<view class="list">
					<view class="head">
						<image src="/static/restaurant/user/wallet.png" mode="widthFix"></image>
						<text>充值</text>
					</view>
					<view class="block">
						<view class="item" v-for="(item,index) in data" :key="item" :class="{cur:cur == index}" @tap="choose(item,index)">
							<text>{{item}}元</text>
						</view>
					</view>
				</view>
				
				<view class="input">
					<input type="text" placeholder="点击输入充值金额" v-model="money" placeholderStyle="color: #999;font-size:28rpx;" />
				</view>
				
				<view class="btn" @tap="recharge">
					立即充值
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	export default {
		data() {
			return {
				data:[500,200,100,50,20,10],
				cur:null,
				money: ''
			}
		},
		computed: {
			...mapState(['user','common'])
		},
		methods: {
			choose(m,n) {
				this.money = m
				this.cur = n;
			},
			async recharge() {
				if(!this.money) return this.$wanlshop.msg('请输入充值金额')
				let res = await this.$api.recharge({
					shop_id:this.common.store.id,
					money:this.money
				})
				if(res.code == 1) {
					console.log(res)
				}
			}
		}
	}
</script>
<style lang="less">
page {
	background-color: #F5F5F5;
}
</style>

<style lang="less" scoped>
	.page {
		padding-top: 38rpx;
	}
	.box {
		width: 700rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin: 0 auto;
		>.head {
			width: 700rpx;
			height: 212rpx;
			background: #FA802A;
			border-radius: 16rpx 16rpx 0 0;
			padding: 0 34rpx;
			box-sizing: border-box;
			padding-top: 24rpx;
			.info {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				image {
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
				}
				> view {
					display: flex;
					flex-direction: column;
					margin-left: 14rpx;
					> text {
						color: #fff;
						font-size: 32rpx;
						font-weight: 500;
					}
					view {
						display: flex;
						justify-content: flex-start;
						align-items: center;
						color: #fff;
						font-size: 30rpx;
					}
				}
			}
		}
		.content {
			background-color: #fff;
			border-radius: 16rpx 16rpx 0 0;
			margin-top: -66rpx;
			width: 100%;
			padding-bottom: 146rpx;
			.money {
				height: 202rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 630rpx;
				border-bottom: 1px dashed #DADADA;
				margin: 0 auto;
				position: relative;
				padding: 0 10rpx;
				&::after,&::before {
					content: '';
					display: inline-block;
					position: absolute;
					bottom: -20rpx;
					width: 40rpx;
					height: 40rpx;
					background-color: #f5f5f5;
					border-radius: 50%;
				}
				&::after {
					left: -56rpx;
				}
				&::before {
					right: -56rpx;
				}
				text {
					font-weight: 500;
					&:nth-child(1) {
						color: #333333;
						font-size: 32rpx;
					}
					&:nth-child(2) {
						color: #000000;
						font-size: 64rpx;
						padding-left: 40rpx;
						position: relative;
						display: flex;
						justify-content: flex-end;
						align-items: center;
						&::after {
							left: 0;
							position: absolute;
							content: "¥";
							display: inline-block;
							font-size: 48rpx;
						}
					}
				}
			}
			
			.list {
				padding: 74rpx 30rpx 20rpx 30rpx;
				.head {
					display: flex;
					justify-content: flex-start;
					align-items: center;
					image {
						width: 52rpx;
						height: 52rpx;
						margin-right: 10rpx;
					}
					text {
						color: #333333;
						font-size: 32rpx;
					}
				}
				.block {
					display: flex;
					justify-content: flex-start;
					flex-wrap: wrap;
					margin-bottom: 116rpx;
					.item {
						width: 196rpx;
						height: 68rpx;
						background: #F6F6F6;
						border-radius: 6rpx;
						margin-top: 30rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						&.cur {
							background-color: #FA802A;
							text {
								color: #fff;
							}
						}
						&:nth-child(2),&:nth-child(5) {
							margin-left: 26rpx;
							margin-right: 26rpx;
						}
						text {
							color: #000000;
							font-size: 28rpx;
						}
					}
				}
				
			}
			.input {
				position: relative;
				padding-left: 60rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				width: 638rpx;
				height: 68rpx;
				margin: 0 auto;
				border-bottom: 1px solid #E0E0E0;
				&::after {
					content: '¥';
					display: inline-block;
					position: absolute;
					left: 0;
					color: #000000;
					font-size: 62rpx;
				}
				input {
					font-size: 50rpx;
					font-weight: normal;
				}
			}
			.btn {
				width: 420rpx;
				height: 84rpx;
				background: #FA802A;
				border-radius: 10rpx;
				margin: 170rpx auto 0;
				line-height: 84rpx;
				text-align: center;
				color: #fff;
				font-size: 36rpx;
				font-weight: 500;
			}
		}
	}
</style>